﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SmartSpace.UI.Silverlight.Web.Metadatas
{
    public class FieldMetadata
    {
        public Guid ID { get; set; }
        public string Name { get; set; }
        public string Caption { get; set; }
        public int OrderIndex { get; set; }
        public bool CanVisit { get; set; }
        public int Length { get; set; }
        /// <summary>
        /// 类型
        /// </summary>
        public string Type { get; set; }
        /// <summary>
        /// 类型:标志数据
        /// </summary>
        public Guid TypeFlag { get; set; }
        /// <summary>
        /// 是否独占一行
        /// </summary>
        public bool IsAbundance { get; set; }

        private bool m_isSaveNullable;

        /// <summary>
        /// 保存时不能为空
        /// </summary>
        public bool IsSaveNullable
        {
            get
            {
                return m_isSaveNullable;
            }
            set
            {
                m_isSaveNullable = value;
                if (!m_isSaveNullable)
                {
                    IsSubmitNullable = m_isSaveNullable;
                }
            }
        }

        /// <summary>
        /// 提交时不能为空
        /// </summary>
        public bool IsSubmitNullable { get; set; }

        public string DefaultValue { get; set; }

        /// <summary>
        /// 是否在列表视图中显示
        /// </summary>
        public bool IsListVisible { get; set; }

        //暂定
        public bool CanModify { get; set; }

        public FieldMetadata()
        {
            IsSaveNullable = true;
            IsSubmitNullable = true;

            CanModify = false;

            IsListVisible = true;
        }
    }
}
